//
//  TravelViewModel.m
//  didacar
//
//  Created by 度周末网络-王腾 on 15/12/18.
//  Copyright © 2015年 dzmmac. All rights reserved.
//

#import "TravelViewModel.h"

@implementation TravelViewModel

-(id)init{
    
    self.mainDataSource = [[NSArray alloc ] init];
    return [super init];
}

-(void)loadData:(DealDataResultBlock)resultBlock{
    
    NSMutableDictionary *postDic = [[NSMutableDictionary alloc ] init];
    
    [postDic setObj:USERINFOManager.getUserInfo.MemberId forKey:@"MemberId"];
    
    WEAKSELF
    [[BaseHttpRequest sharedInstance] sendRequestToPost:@"TicketOrder.GetMyTrip" withData:postDic alertMessage:@"" success:^(NSDictionary *dicData) {
        
        for (NSDictionary *dic in [dicData objectForKey:@"MyTripList"]) {
            MyTripEntity *entity = [[MyTripEntity alloc ] initWithDictionary:dic];
            [weakSelf.resultList addObject:entity];
        }
        
        
        
        weakSelf.selectedTime = [[weakSelf.resultList firstObject] TripDate];
        weakSelf.mainDataSource = [[weakSelf.resultList firstObject] myTripDetailList];
        resultBlock(1,nil,nil);
    } error:^(NSString *errorMsg) {
         resultBlock(0,nil,errorMsg);
    }];
    
    
    
    
    
}

@end
